package cn.imnaer.service.persistence.model;

import java.util.Date;

/**
 * Created by Administrator on 2015/5/27.
 */
public class TemporarySession {
    private String sendUserId;
    private String sendUserName;
    private String content;
    private Long createTime;

    public String getSendUserId() {
        return sendUserId;
    }

    public void setSendUserId(String sendUserId) {
        this.sendUserId = sendUserId;
    }

    public String getSendUserName() {
        return sendUserName;
    }

    public void setSendUserName(String sendUserName) {
        this.sendUserName = sendUserName;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public TemporarySession buildSession(String content, FriendRequest request, String sendUserId) {
        if(sendUserId.equals(request.getAcceptUserId())) {
            this.setSendUserId(request.getAcceptUserId());
            this.setSendUserName(request.getAcceptUserName());
            request.setIsUnReadForSendUser(true);
        }else {
            this.setSendUserId(request.getSendUserId());
            this.setSendUserName(request.getSendUserName());
            request.setIsUnReadForAcceptUser(true);
        }
        this.setCreateTime(new Date().getTime());
        this.setContent(content);

        return this;
    }
}
